import 'package:flutter/material.dart';

main(){
  runApp(Demo62App());
}

class Demo62App extends StatefulWidget {
  const Demo62App({Key? key}) : super(key: key);

  @override
  _Demo62AppState createState() => _Demo62AppState();
}

class _Demo62AppState extends State<Demo62App> {

  List<Tab> tabs = [
    Tab(text: '明教',),
    Tab(text: '霸道',),
    Tab(text: '天策',),
    Tab(text: '纯阳',),
    Tab(text: '少林',),
    Tab(text: '长健',),
    Tab(text: '七秀',),
    Tab(text: '五毒',),
    Tab(text: '天门',),
    Tab(text: '唐门',),
    Tab(text: '武当',),
    Tab(text: '昆仑',),
  ];


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        length: tabs.length,
        child: Scaffold(

          appBar: AppBar(

            title: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Expanded(child: TabBar(
                  tabs: tabs,
                  isScrollable: true,
                  indicatorColor: Colors.purpleAccent,
                ))
              ],
            ),

            // bottom: TabBar(
            //   tabs: tabs,
            //   isScrollable: true,
            //   indicatorColor: Colors.purpleAccent,
            // ),
          ),
          body: TabBarView(
            children: tabs.map((e) {
              return Center(child: Text(e.text??"其他"),);
            }).toList(),
          ),
        ),
      ),
    );
  }
}

